<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri= "http://java.sun.com/jsp/jstl/core" prefix= "c" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath %>" />
		<head>
		<meta charset="UTF-8">
		<title></title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="css/global.css" media="all" />
	<style type="text/css">
		table td,th { font-size: 14px !important;  white-space: nowrap;}
	</style>	
	</head>
	
	<body>
		<div id="tempybbt" class="layui-hide">
		<div class="layui-form-item" >
			<label class="layui-form-label">夜班次数</label>
			<div class="layui-input-inline">
				<input type="number" name="ybbttimes" placeholder="请输入" autocomplete="off"
					class="layui-input" >
			</div>
			<div class="layui-form-mid layui-word-aux">次</div>
		</div>
	</div>

		<div class="admin-main">

			<blockquote class="layui-elem-quote">

				<form class="layui-form layui-box"  style="margin-top: 1.5em;" id="search-form">
				<c:if test="${currentuser.right == 14 }">
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-inline">
						<input type="text" name="xm" id="sh-xm" placeholder="姓名.." autocomplete="off" class="layui-input"  >
					</div>
					<label class="layui-form-label">性别</label>
					<div class="layui-input-inline">
						<select name="xb" lay-verify="">
						  <option value="" >选择性别</option>
						</select> 
					</div>
					<label class="layui-form-label">学历</label>
					<div class="layui-input-inline">
						<select name="xl" lay-verify="">
						  <option value="">请选择学历</option>
						</select> 
					</div>
					<label class="layui-form-label">民族</label>
					<div class="layui-input-inline">
						<select name="mz" lay-verify="">
						  <option value="">请选择名族</option>
						</select> 
					</div>
				</div>
				</c:if>
				<div class="layui-form-item">
				<c:if test="${currentuser.right == 14 }">
					<label class="layui-form-label">政治面貌</label>
					<div class="layui-input-inline">
						<select name="zzmm" lay-verify="">
						  <option value="">请选政治面貌</option>
						</select> 
					</div>
					<label class="layui-form-label">所在部门</label>
					<div class="layui-input-inline">
						<select name="szbm" lay-verify="" lay-search>
						  <option value="">请选所在部门(可搜索)</option>
						</select> 
					</div>
					</c:if>
					<label class="layui-form-label">日期</label>
					<div class="layui-input-inline">
						 <input type="text" name="start"  lay-verify="date" placeholder="开始时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
					</div>
					<div class="layui-form-mid">-</div>
					<div class="layui-input-inline">
						 <input type="text" name="end" lay-verify="date" placeholder="结束时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
					</div>
					<div class="layui-input-inline">
					<button  lay-submit lay-filter="search" class="layui-btn layui-btn" >
					<i class="layui-icon">&#xe615;</i> 搜索
					</button>
					</div>
				</div>
				<c:if test="${currentuser.right == 14 }">
				<a href="javascript:;" class="layui-btn layui-btn" id="export">
					<i class="fa fa-shopping-cart" aria-hidden="true"></i> 导出信息
				</a>
				</c:if>
				
				</form>
			</blockquote>
			<fieldset class="layui-elem-field">
				<legend>员工工资条列表</legend>
				<div style="width: 120em;overflow: auto;">
				<div class="layui-field-box layui-form">
					<table class="layui-table admin-table">
						<thead>
							<tr>
								<th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary"></th>
								<th>员工编码</th>
								<th>姓名</th>
							
							    <th>年份</th>
							    <th>月份</th>
								<!-- <th>入职日期</th>
								<th>所在部门</th>
								<th>岗位类型</th>
								<th>用工性质</th>
								<th>负责项目</th> -->
								<th>岗级工资</th>
								<th>工龄工资</th>
								<th>专业资格补贴</th>
								<th>通讯补贴</th>
								<th>交通补贴</th>
								<th>出车补贴</th>
								<th>夜班补贴</th>
								<th>加班补贴</th>
								<th>适岗补贴</th>
								<th>其它</th>
								<th>绩效考核工资</th>
								<th>养老保险</th>
								<th>失业保险</th>
								<th>医疗保险</th>
								<th>大病保险</th>
								<th>公积金</th>
								
								<th>个人所得税(工资 )</th>
								<th>个人扣款</th>
								<th>应发工资</th>
								<th>实发工资</th>
								<th>存折</th>
								<th>应发奖金</th>
								<th>个人所得税(奖金)</th>
								<th>实发奖金</th>
							</tr>
						</thead>
						<tbody id="content">
						</tbody>
						<tfoot >
							<tr>
								<th colspan="35 ">
									<div class="admin-table-page">
										<div id="paged" class="page">
										</div>
									</div>
								</th>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
			</fieldset>
		
		</div>
		<!--模板-->
		<script type="text/html" id="tpl">
			{{# layui.each(d.list.list, function(index, item){ }}
			<tr>
				<td><input type="checkbox" lay-skin="primary"></td>
				<td>{{ vnull(item.ygbm) }}</td>
				<td>{{ vnull(item.xm) }}</td>

				<td>{{ vnull(item.gyear) }}</td>
				<td>{{ vnull(item.gmonth) }}</td>
			
				<td>{{ vnull(item.gjgz) }}</td>
				<td>{{ vnull(item.glgz) }}</td>
				<td>{{ vnull(item.zyzgbt) }}</td>
				<td>{{ vnull(item.txbt) }}</td>
				<td>{{ vnull(item.jtbt) }}</td>
				<td>{{ vnull(item.ccbt) }}</td>
				<td>{{ vnull(item.ybbt) }}</td>
				<td>{{ vnull(item.jbgz) }}</td>
				<td>{{ vnull(item.sgbt) }}</td>
				<td>{{ vnull(item.qt) }}</td>
				<td>{{ vnull(item.jxkhgz) }}</td>
				<td>{{ vnull(item.ylbx) }}</td>
				<td>{{ vnull(item.sybx) }}</td>
				<td>{{ vnull(item.ylbxx) }}</td>
				<td>{{ vnull(item.dbbx) }}</td>
				<td>{{ vnull(item.gjj) }}</td>

				<td>{{ vnull(item.grsds) }}</td>
				<td>{{ vnull(item.grkk) }}</td>
				<td>{{ vnull(item.yfgz) }}</td>
				<td>{{ vnull(item.sfgz) }}</td>
				<td>{{ vnull(item.cz) }}</td>
				<td>{{ vnull(item.yfjj) }}</td>
				<td>{{ vnull(item.grsdss) }}</td>
				<td>{{ vnull(item.sfjj) }} <a href="javascript:;" data-name='{{ JSON.stringify(item) }}' data-opt="edit" class="layui-hide"></a></td>
				
			</tr>
			{{# }); }}
		</script>
		<script type="text/javascript" src="plugins/layui/layui.js"></script>
		<script>
		
			layui.config({
				base: 'js/'
			});
			//身份证号算年龄 
            function goage(n){
            	var a = new Date().getFullYear();
            	var b =parseInt(n.substr(6,4));
            	return a-b;
            }
            // 验证null/undefine
            function vnull(str){
                if(str==null || str==undefined){
					return "";
                    }else{
					return str;
                        }
                }
            
			layui.use(['paging', 'form', 'laydate', 'upload'], function() {
				var $ = layui.jquery,
					paging = layui.paging(),
					layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
					layer = layui.layer, //获取当前窗口的layer对象
					form = layui.form();
				var _data = {};
				//全局的AJAX访问，处理AJAX清求时SESSION超时
				$.ajaxSetup({
				    contentType:"application/x-www-form-urlencoded;charset=utf-8",
				    complete:function(XMLHttpRequest,textStatus){
				          //通过XMLHttpRequest取得响应头，sessionstatus           
				          var sessionstatus=XMLHttpRequest.getResponseHeader("sessionstatus"); 
				          loginUrl = XMLHttpRequest.getResponseHeader("location"); 
				          if(sessionstatus=='00004'){
				               //这里怎么处理在你，这里跳转的登录页面
				        	 // if( window.top != window.self ){
				  				window.top.location = loginUrl;
				  			//}
				       }
				    }
				});
				
				//公用ajax方法 
				var jsajax = function(type, url,_data){  
		              $.ajax({
						type: type,
						url:  url,
						async: false,
						data: _data,
						dataType: 'json',
						success: function(result, status, xhr) {
							if(result.flag){
							 	$(_data.ele).val( result.count);
								}
							layerTips.msg(result.msg);
							}
					});
		          }
			var data = {};
			var loadtab = function(data){ 
					paging.init({
					url: 'user/findusersalarydatas',  //地址
					elem: '#content', //内容容器
					params: data,
					type: 'post',
					tempElem: '#tpl', //模块容器
					pageConfig: { //分页参数配置
						elem: '#paged', //分页容器
						pageSize: 10 //分页大小
					},
					success: function() { //渲染成功的回调
						//alert('渲染成功');
					},
					fail: function(msg) { //获取数据失败的回调
						//alert('获取数据失败')
					},
					complate: function() { //完成的回调
						//alert('处理完成');
						//重新渲染复选框
						form.render('checkbox');
						form.on('checkbox(allselector)', function(data) {
							var elem = data.elem;

							$('#content').children('tr').each(function() {
								var $that = $(this);
								//全选或反选
								$that.children('td').eq(0).children('input[type=checkbox]')[0].checked = elem.checked;
								form.render('checkbox');
							});
						});

						//绑定所有编辑按钮事件						
						$('#content').children('tr').each(function() {
							var $that = $(this);
							$that.children('td:last-child').children('a[data-opt=edit]').on('click', function() {
								//JSON.parse(jsonstr); //可以将json字符串转换成json对象 
								//JSON.stringify(jsonobj); 
								//layer.msg($(this).data('name').xm);
								var data = $(this).data('name');
								loadform(data);
								});
						});
					}
				});
			}
			
				//获取所有选择的列
				$('#export').on('click', function() {
					var names = '';
					$('#content').children('tr').each(function() {
						var $that = $(this);
						var $cbx = $that.children('td').eq(0).children('input[type=checkbox]')[0].checked;
						if($cbx) {
							var n = $that.children('td:last-child').children('a[data-opt=edit]').data('name').salarydataid;
							names += n + ',';
						}
					});
                /*   if(!names){
					layer.msg('请至少选择一条');
                  }else{
						window.location.href="user/salarydataexplortexcel?ids="+names;
                  } */
					$.get('temp/check-col.html', null, function(form) {
						 addBoxIndex = layer.open({
							type: 1,
							title: '下载设置',
							content: form,
							btn: ['下载', '取消'],
							shade: false,
							offset: ['100px', '30%'],
							area: ['600px', '400px'],
							zIndex: 19950924,
							maxmin: true,
							yes: function(index) {
								//触发表单的提交事件
								//设置提交地址
								$('form.layui-form').find('button[lay-filter=edit]').click();
							},
							full: function(elem) {
								var win = window.top === window.self ? window : parent.window;
								$(win).on('resize', function() {
									var $this = $(this);
									elem.width($this.width()).height($this.height()).css({
										top: 0,
										left: 0
									});
									elem.children('div.layui-layer-content').height($this.height() - 95);
								});
							},
							success: function(layero, index) {
								var ltab ;//查询对应的列名和注释
								$.ajax({
									type: 'post',
									url:  'user/colsandcoms',
									data: {tab: 'G_USER_SALARY_DATA'},
									async: false,
									dataType: 'json',
									success: function(result, status, xhr) {
										if(result.flag){

											latab = result.list;	
											}
										}
								});

								var html = "";
								   $(latab).each(function(i,item){

										html += "<input type='checkbox' name='col'  data-val ='"+JSON.stringify(item)+"' title='"+item.comments+"' > ";
										
									   });
								 $(layero).find('#check-col').html(html);

								 var form  = layui.form();
								 form.render();
								 
								 form.on('submit(edit)', function(data) {
                                       var cols="",coms="";
									     $(layero).find('input[name="col"]').each(function(i, item){
										     if(item.checked){
										     cols += $(item).data('val').column_name+",";
										     coms += $(item).data('val').comments+",";
										     }
										     });
									     var url = 'user/salarydataexplortexcel?tabname='+data.field.tabname+'&titlename='+data.field.titlename+'&cols='+cols+'&coms='+coms+'&names='+names;
									     layer.close(index);
									     window.location.href=url;
									     return false;
											})
									
								},
							end: function() {
									addBoxIndex = -1;
								}
							});
						});
					});

				// 部门职位
				var addorganiz = function(a, o){
					$.ajax({
						type: 'get',
						url:  'organiz/findbylevl',
						data: {level:a},
						async: false,
						dataType: 'json',
						success: function(result, status, xhr) {
							if(result.flag){
								$(result.list).each(function(i,item){
							      $(o).append("<option value='" +item.bmbh+"'>"+item.oname+"</option>");
								});
								}
							}
					});
				}
		  		//加载字典项
				var doDectAjax=function(){
					$.ajax({type: 'get',url:  'selectdect',
						//data: data.field,
						async: false,dataType: 'json',success: function(result, status, xhr) {
							if(result.flag){
									$(result.list).each(function(i,item){
											switch (item.dtype){
											case "EDU" :
												$("select[name='xl']").append("<option value='" +item.dname+"'>"+item.dname+"</option>");
												break;
										 	case "SEX" :
												$("select[name='xb']").append("<option value='" +item.dname+"'>"+item.dname+"</option>");
												break;
											case "NATION" :
												$("select[name='mz']").append("<option value='" +item.dname+"'>"+item.dname+"</option>");
												break; 
											case "POL" :
												$("select[name='zzmm']").append("<option value='"+item.dname+"'>"+item.dname+"</option>");
												break;
											default:
												break;
												}
										});
								}
							}
					});
					}
				form.on('submit(search)', function(data){
					  loadtab(data.field)
					  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
					});
				loadtab(data);
				addorganiz("B", $('#search-form select[name="szbm"]'));
				doDectAjax();
				form.render();
			});
		</script>
	</body>
	</body>

</html>